// createRouter //创建router实例对象
// createWebHistory //路由为history
import { createRouter, createWebHistory } from 'vue-router'
import Login from '@/views/Login/index.vue'
import Layout from '@/views/Layout/index.vue'
import Home from '@/views/Home/index.vue'
import CameramanAdmin from '@/views/CameramanAdmin/index.vue'
import PictureAdmin from '@/views/PictureAdmin/index.vue'
import Resource from '@/views/Resource/index.vue'



const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path:'',
      component:Login
    },
    {
      path:'/layout',
      component:Layout,
      children:[
        {
          path:'/home',
          component:Home,
          meta:{breadcrumb:'首页'}
        },
        {
          path:'/cameramanadmin',
          component:CameramanAdmin,
          meta:{breadcrumb:'摄影师管理'},
        },
        {
          path:'/pictureadmin',
          component:PictureAdmin,
          meta:{breadcrumb:'图片管理'},
        },
        {
          path:'/resource',
          component:Resource,
          meta:{titbreadcrumble:'资源管理'},
        }
      ]
    }
  ]
})

// router.beforeEach((to, from, next) => {
//   // 检查用户是否已登录以及是否需要登录
//   if (!isLoggedIn() && to.meta.requiresAuth !== false) {
//     // 如果未登录且尝试访问需要登录的页面，则重定向到登录页面
//     next('/login');
//   } else {
//     // 否则，继续到目标路由
//     next();
//   }
// });


export default router
